package com.chen.demoa.service.impl;

import com.chen.demoa.bean.Demo;
import com.chen.demoa.dao.DemoMapper;
import com.chen.demoa.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.List;


@Service
public class DemoServiceImpl  implements DemoService {

    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private DemoMapper demoMapper;
    @Override
    public List<Demo> findAll() {
        List<Demo> list=  demoMapper.findAll();
        return list;
    }

    @Override
    public List<Demo> findAll1() {
        Demo demo = new Demo();
        demo.setId("110");
        demo.setName("ceshi0");
        demoMapper.create(demo);
        rm2();
        rm3();
        return null;
    }

    @Override
    public void create() {
        Demo demo = new Demo();
        demo.setId("1sdsds");
        demo.setName("ceshiss0");
        demoMapper.create(demo);
        int a=1/0;

    }

    private void rm2() {
        restTemplate.getForEntity("http://demo-a-1/demo/test1", null);
    }
    private void rm3(){
        restTemplate.getForEntity("http://demo-a-2/demo/test1", null);
    }
}
